package com.xinxin.blockchain.api.controller;

import com.xinxin.base.controller.BaseController;
import com.xinxin.base.entity.ApiResult;
import com.xinxin.blockchain.dto.MobileLoginDTO;
import com.xinxin.blockchain.service.IMemberService;
import com.xinxin.blockchain.vo.MemberLoginVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author ys
 * @date 2021/5/20
 */
@Api(tags = "会员接口")
@Validated
@RestController
@RequestMapping("member")
public class MemberController extends BaseController {

    @Autowired
    private IMemberService memberService;

    @ApiOperation("短信验证码登陆")
    @PostMapping("login/mobile")
    public ApiResult<MemberLoginVO> mobileLogin(@Valid @ModelAttribute MobileLoginDTO dto) {
        MemberLoginVO memberLoginVO = memberService.mobileLogin(dto.getCountryCode(), dto.getMobile(), dto.getSmsCode());
        return ApiResult.success(memberLoginVO);
    }
}
